//
//  HMTitleBtn.m
//  SinaWeiBo
//
//  Created by WGP on 16/4/13.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "HMTitleBtn.h"

@implementation HMTitleBtn

-(void)setHighlighted:(BOOL)highlighted
{}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGRect labelFrame = self.titleLabel.frame;
    labelFrame.origin.x = 0;
    self.titleLabel.frame = labelFrame;
    
    CGRect imageFrame = self.imageView.frame;
    imageFrame.origin.x = self.titleLabel.bounds.size.width + 5;
    self.imageView.frame = imageFrame;
    
}

+(instancetype)titleBtnWith:(NSString *)title imageName:(NSString *)imageName
{
    HMTitleBtn *btn = [[HMTitleBtn alloc] init];
    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [btn sizeToFit];
    
    return btn;
}

-(void)startAnimation
{
    [UIView animateWithDuration:HMAnimationInterver animations:^{
        if(self.selected)
        {
            self.imageView.transform = CGAffineTransformMakeRotation(M_PI-0.01);
        }else
        {
            self.imageView.transform = CGAffineTransformIdentity;
        }
    }];
}

@end
